home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1995 August: Tool Chest / Dev.CD Aug 95 TC / Dev.CD Aug 95 TC.toast / Tool Chest / Interfaces / UniversalInterfaces 2.0 / PInterfaces / TranslationExtensions.p < prev    next >
Encoding:
Text File  |  1995-04-18  |  6.2 KB  |  199 lines  |  [TEXT/MPS ]

  1. {
  2.      File:        TranslationExtensions.p
  3.  
  4.      Contains:    Macintosh Easy Open Translation Extension Interfaces.
  5.  
  6.      Version:    Technology:    Macintosh Easy Open 1.1
  7.                  Package:    Universal Interfaces 2.0 in “MPW Latest” on ETO #17
  8.  
  9.      Copyright:    © 1984-1995 by Apple Computer, Inc.
  10.                  All rights reserved.
  11.  
  12.      Bugs?:        If you find a problem with this file, use the Apple Bug Reporter
  13.                  stack.  Include the file and version information (from above)
  14.                  in the problem description and send to:
  15.                      Internet:    apple.bugs@applelink.apple.com
  16.                      AppleLink:    APPLE.BUGS
  17.  
  18. }
  19.  
  20. {$IFC UNDEFINED UsingIncludes}
  21. {$SETC UsingIncludes := 0}
  22. {$ENDC}
  23.  
  24. {$IFC NOT UsingIncludes}
  25.  UNIT TranslationExtensions;
  26.  INTERFACE
  27. {$ENDC}
  28.  
  29. {$IFC UNDEFINED __TRANSLATIONEXTENSIONS__}
  30. {$SETC __TRANSLATIONEXTENSIONS__ := 1}
  31.  
  32. {$I+}
  33. {$SETC TranslationExtensionsIncludes := UsingIncludes}
  34. {$SETC UsingIncludes := 1}
  35.  
  36.  
  37. {$IFC UNDEFINED __MEMORY__}
  38. {$I Memory.p}
  39. {$ENDC}
  40. {    Types.p                                                        }
  41. {        ConditionalMacros.p                                        }
  42. {    MixedMode.p                                                    }
  43.  
  44. {$IFC UNDEFINED __FILES__}
  45. {$I Files.p}
  46. {$ENDC}
  47. {    OSUtils.p                                                    }
  48.  
  49. {$IFC UNDEFINED __QUICKDRAW__}
  50. {$I Quickdraw.p}
  51. {$ENDC}
  52. {    QuickdrawText.p                                                }
  53.  
  54. {$IFC UNDEFINED __COMPONENTS__}
  55. {$I Components.p}
  56. {$ENDC}
  57.  
  58. {$PUSH}
  59. {$ALIGN MAC68K}
  60. {$LibExport+}
  61.  
  62. CONST
  63.     kSupportsFileTranslation    = 1;
  64.     kSupportsScrapTranslation    = 2;
  65.     kTranslatorCanGenerateFilename = 4;
  66.  
  67.     
  68. TYPE
  69.     FileType = OSType;
  70.  
  71.     ScrapType = ResType;
  72.  
  73.     TranslationAttributes = LONGINT;
  74.  
  75.  
  76. CONST
  77.     taDstDocNeedsResourceFork    = 1;
  78.     taDstIsAppTranslation        = 2;
  79.  
  80.  
  81. TYPE
  82.     FileTypeSpec = RECORD
  83.         format:                    FileType;
  84.         hint:                    LONGINT;
  85.         flags:                    TranslationAttributes;                    { taDstDocNeedsResourceFork, taDstIsAppTranslation}
  86.         catInfoType:            OSType;
  87.         catInfoCreator:            OSType;
  88.     END;
  89.  
  90.     FileTranslationList = RECORD
  91.         modDate:                LONGINT;
  92.         groupCount:                LONGINT;
  93.         {     unsigned long    group1SrcCount;}
  94.         {     unsigned long    group1SrcEntrySize = sizeof(FileTypeSpec);}
  95.         {  FileTypeSpec    group1SrcTypes[group1SrcCount]}
  96.         {  unsigned long    group1DstCount;}
  97.         {  unsigned long    group1DstEntrySize = sizeof(FileTypeSpec);}
  98.         {  FileTypeSpec    group1DstTypes[group1DstCount]}
  99.     END;
  100.  
  101.     FileTranslationListPtr = ^FileTranslationList;
  102.     FileTranslationListHandle = ^FileTranslationListPtr;
  103.  
  104.     ScrapTypeSpec = RECORD
  105.         format:                    ScrapType;
  106.         hint:                    LONGINT;
  107.     END;
  108.  
  109.     ScrapTranslationList = RECORD
  110.         modDate:                LONGINT;
  111.         groupCount:                LONGINT;
  112.         {     unsigned long        group1SrcCount;}
  113.         {     unsigned long        group1SrcEntrySize = sizeof(ScrapTypeSpec);}
  114.         {  ScrapTypeSpec        group1SrcTypes[group1SrcCount]}
  115.         {  unsigned long        group1DstCount;}
  116.         {     unsigned long        group1DstEntrySize = sizeof(ScrapTypeSpec);}
  117.         {  ScrapTypeSpec        group1DstTypes[group1DstCount]}
  118.     END;
  119.  
  120.     ScrapTranslationListPtr = ^ScrapTranslationList;
  121.     ScrapTranslationListHandle = ^ScrapTranslationListPtr;
  122.  
  123. { definition of callbacks to update progress dialog}
  124.     TranslationRefNum = LONGINT;
  125.  
  126. {****************************************************************************************
  127. *
  128. * This routine sets the advertisement in the top half of the progress dialog.
  129. * It is called once at the beginning of your DoTranslateFile routine.
  130. *
  131. * Enter:    refNum            Translation reference supplied to DoTranslateFile.
  132. *            advertisement    A handle to the picture to display.  This must be non-purgable.
  133. *                            Before returning from DoTranslateFile, you should dispose
  134. *                            of the memory.  (Normally, it is in the temp translation heap
  135. *                            so it is cleaned up for you.)
  136. *
  137. * Exit:    returns            noErr, paramErr, or memFullErr
  138. }
  139.  
  140. FUNCTION SetTranslationAdvertisement(refNum: TranslationRefNum; advertisement: PicHandle): OSErr;
  141.     {$IFC NOT GENERATINGCFM}
  142.     INLINE $7002, $ABFC;
  143.     {$ENDC}
  144. {****************************************************************************************
  145. *
  146. * This routine updates the progress bar in the progress dialog.
  147. * It is called repeatedly from within your DoTranslateFile routine.
  148. * It should be called often, so that the user will get feedback if he tries to cancel.
  149. *
  150. * Enter:    refNum        translation reference supplied to DoTranslateFile.
  151. *            progress    percent complete (0-100)
  152. *
  153. * Exit:        canceled    TRUE if the user clicked the Cancel button, FALSE otherwise
  154. *            returns        noErr, paramErr, or memFullErr
  155. }
  156. FUNCTION UpdateTranslationProgress(refNum: TranslationRefNum; percentDone: INTEGER; VAR canceled: BOOLEAN): OSErr;
  157.     {$IFC NOT GENERATINGCFM}
  158.     INLINE $7001, $ABFC;
  159.     {$ENDC}
  160. { ComponentMgr selectors for routines}
  161.  
  162. CONST
  163.     kTranslateGetFileTranslationList = 0;                        { component selectors}
  164.     kTranslateIdentifyFile        = 1;
  165.     kTranslateTranslateFile        = 2;
  166.     kTranslateGetTranslatedFilename = 3;
  167.     kTranslateGetScrapTranslationList = 10;                        { skip to scrap routines}
  168.     kTranslateIdentifyScrap        = 11;
  169.     kTranslateTranslateScrap    = 12;
  170.  
  171. { Routines to implment in a file translation extension}
  172. TYPE
  173.     DoGetFileTranslationListProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; translationList: FileTranslationListHandle): ComponentResult; }
  174.  
  175.     DoIdentifyFileProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; (CONST)VAR theDocument: FSSpec; VAR docType: FileType): ComponentResult; }
  176.  
  177.     DoTranslateFileProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; refNum: TranslationRefNum; (CONST)VAR sourceDocument: FSSpec; srcType: FileType; srcTypeHint: LONGINT; (CONST)VAR dstDoc: FSSpec; dstType: FileType; dstTypeHint: LONGINT): ComponentResult; }
  178.  
  179.     DoGetTranslatedFilenameProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; dstType: FileType; dstTypeHint: LONGINT; VAR theDocument: FSSpec): ComponentResult; }
  180.  
  181. { Routine to implement in a scrap translation extension}
  182.     DoGetScrapTranslationListProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; list: ScrapTranslationListHandle): ComponentResult; }
  183.  
  184.     DoIdentifyScrapProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; dataPtr: UNIV Ptr; dataLength: Size; VAR dataFormat: ScrapType): ComponentResult; }
  185.  
  186.     DoTranslateScrapProcPtr = ProcPtr;  { FUNCTION (self: ComponentInstance; refNum: TranslationRefNum; srcDataPtr: UNIV Ptr; srcDataLength: Size; srcType: ScrapType; srcTypeHint: LONGINT; dstData: Handle; dstType: ScrapType; dstTypeHint: LONGINT): ComponentResult; }
  187.  
  188.  
  189. {$ALIGN RESET}
  190. {$POP}
  191.  
  192. {$SETC UsingIncludes := TranslationExtensionsIncludes}
  193.  
  194. {$ENDC} {__TRANSLATIONEXTENSIONS__}
  195.  
  196. {$IFC NOT UsingIncludes}
  197.  END.
  198. {$ENDC}
  199.